package yto.freemarker.springbootstudy.jdkdynamic;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * 代理类
 *
 * @author dongxing
 * @create 2018-07-12 8:47
 **/
public class UserServiceInvocationHandler implements InvocationHandler {


    private UserService userService;

    public UserServiceInvocationHandler(UserService userService) {
        this.userService = userService;
    }


    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("前置增强！");
        Object invoke = method.invoke(userService, args);
        System.out.println("后置增强！");
        return invoke;

    }
}
